package com.signal;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TableLayout;
import android.widget.TableRow;

public class TelaResumo extends Activity{

	private Gallery mGallery; 

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.layout_tela_resumo);

		SharedResources.sFotos.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
		SharedResources.sFotos.add(BitmapFactory.decodeResource(getResources(), R.drawable.signal_image));
		SharedResources.sFotos.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
		SharedResources.sFotos.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
		
		
		mGallery = (Gallery)findViewById(R.id.tela_resumo_gallery);
		mGallery.setAdapter(new ImageAdapter(this, SharedResources.sFotos));
		//mGallery.set
		//TODO
	}



	public class ImageAdapter extends BaseAdapter {
		
		private Context cont;
		private ArrayList<Bitmap> images;
		private int galleryItemBg;
		
		public ImageAdapter(Context c, ArrayList<Bitmap> imgs) {
			cont = c;
			this.images = imgs;
			TypedArray typArray = obtainStyledAttributes(R.styleable.Gallery1);
			galleryItemBg = typArray.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0);
			typArray.recycle();			
		}

		public int getCount() {
			return images.size();
		}

		public Object getItem(int position) {
			return position;
		}

		public long getItemId(int position) {
			return position;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			ImageView imgView = new ImageView(cont);
			imgView.setImageBitmap(images.get(position));
			imgView.setLayoutParams(new Gallery.LayoutParams(200,200));
			//imgView.setAdjustViewBounds(true);
			//imgView.setLayoutParams(new Gallery.LayoutParams(80, 70));
			imgView.setScaleType(ImageView.ScaleType.FIT_XY);
			imgView.setBackgroundResource(galleryItemBg);

			return imgView;
		}
	}

}

